% Test the function makeppft filter.
%
% Yoel Shkolnisky, December 2010.
explim=7;
for precond=0:1
    for n=2.^(1:explim)
        precision='double';
        if n > 2^(explim-1)
            precision='single';
        end
        A=rand(n,n,n);
        if precond
            tic;B=preconditionedAdjointPPFT3D(optimizedPPFT3D(A,precision),precision);t1=toc;
        else
            tic;B=optimizedAdjointPPFT3D(optimizedPPFT3D(A,precision),precision);t1=toc;
        end
        
        L=3*n-2; %n+2n-1-1
        filename=sprintf('filters%sH3Dfilter%dprecond%dprecision%s.dat',filesep,n,precond,precision);
        if exist(filename,'file')
            H=load3DHFilter(filename,precision);
        else
            H=save3DHFilter(filename,n,precond,precision);
        end

        Hhat=fftn(H.filter,[L L L]);

        tic;
        Ahat=fftn(A,[L L L]);
        Cc=ifftn(Ahat.*Hhat,[L L L]);
        Cc=Cc(n:2*n-1,n:2*n-1,n:2*n-1);
        t2=toc;

        reportTestResult(n,(norm(B(:)-Cc(:))./norm(B(:))),t1/t2,precision);    
    end
end